#include "Measurer_Node.h"
Measurer_Node::Measurer_Node():parent(0),left(0),right(0){	

}
Measurer_Node::Measurer_Node(Measurer_Node* p):left(0),right(0){
	parent = p;	
}



void Measurer_Node::addSpace(ProSpace* space){
		spaces.push_back(space);
}
ProSpace& Measurer_Node::getSpace(int index){
		
	return *spaces[index];
}
const int Measurer_Node::sizeOf() const{
	return spaces.size();
}
void Measurer_Node::output(int index) const{
	for(int i=0; i<spaces.size();i++){
		spaces[i]->output(index);
	}
}
void Measurer_Node::updateSpace(ProSpace* sp, int index){
	spaces[index] = sp;
}

Measurer_Node::~Measurer_Node(){
	delete parent;
	delete left;
	delete right;
	parent = 0;
	left = 0;
	right = 0;
	int i = 0;
	for (i=0; i< spaces.size();i++){
		delete spaces[i];
		spaces[i] = 0;
	}
}
void Measurer_Node::addLeftChildNode(ProSpace* space){
	if(!left){
		left = new Measurer_Node();
		left->parent = this;
	}
	if(space){
		left->addSpace(space);
	}
}
void Measurer_Node::addRightChildNode(ProSpace* space){
	if(!right){
		
		right = new Measurer_Node();
		right->parent = this;
	}
	if(space){
		right->addSpace(space);
	}
}

Measurer_Node* Measurer_Node::getLeftNode() const{
	return left;
}
Measurer_Node* Measurer_Node::getRightNode() const{
	return right;
}
Measurer_Node* Measurer_Node::getParentNode() const{
	return parent;
}
bool Measurer_Node::isLeftNodeEmpty() const{
	return (left==0);
}
bool Measurer_Node::isRightNodeEmpty() const{
	return (right==0);
}
